Modern computer systems can map peripheral control registers into a single uniform memory space. The memory space can thus include both peripheral control registers and traditional memories like Dynamic Random Access Memory (DRAM) and hard disk drives. The peripherals can be controlled by programming the peripheral control registers using load and store instructions issued by a processor.
FIG. 1 shows a diagram of an example memory map 100. Regions of the memory map, e.g., 102, 104, 106, and 108, correspond to physical memory. Memory can be, for example, DRAM, peripheral control registers, Flash memory, hard disk memory, and so on.
In FIG. 1, regions 102 and 104 represent peripheral control registers. Region 102 corresponds to a Universal Asynchronous Receiver/Transmitter (UART) and region 104 corresponds to a Pulse-Width Modulator (PWM). Region 106 corresponds to Flash memory, and region 108 corresponds to Random Access Memory (RAM), e.g., DRAM.
Memory regions can contain sub-regions. For example, region 102 contains UART control registers 110, 112, 114, and 116. A UART can be configured by writing values to UART control registers. Data for the UART to transmit is written to the transmit holding register 112, and data the UART has received is read from the receive holding register 110. The baud rate can be configured by writing a value to the baud rate register 114. Other control information, e.g., parity, can be written to a control register 116.
In various systems, preventing erroneous access to critical peripherals is advantageous. An example of such a peripheral is a PWM used to control electric motors. The PWM outputs a pulse train that controls the motor. If the control registers of the PWM module are inadvertently updated with erroneous values, the motor can start operating out of control, possibly causing damage to the application and the environment surrounding it. Inadvertent access can be caused by, for example, errors in software code, electrical noise, and the like.